﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace GetComics.Silverlight
{
    public class Dragger : IMovable
    {
        private bool _dragX;
        private bool _dragY;

        public Dragger(bool X, bool Y)
        {
            if ((!X && !Y))
                throw new ArgumentException("Нельзя блокировать обе координаты");
            _dragX = X;
            _dragY = Y;
        }

        public void Move(Point destination, FrameworkElement element)
        {
            TranslateTransform trTrans = ((TransformGroup)element.RenderTransform).GetTransform<TranslateTransform>();
            if (_dragX && _dragY)
            {
                trTrans.X = destination.X;
                trTrans.Y = destination.Y;
            }
            else if (_dragX)
                trTrans.X = destination.X;
            else if (_dragY)
                trTrans.Y = destination.Y;
        }
    }
}
